from wordcloud import WordCloud
import jieba
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
text = open("resource/英文内容.txt").read()# 读取内容
mask = np.array(Image.open("resource/五角星.png")) # 生成图片模板
# mask = np.array(Image.open("resource/心形.png")) # 生成图片模板
wc = WordCloud(mask = mask,mode='RGBA', background_color=None).generate(text=text) # 英文分词
plt.imshow(wc, interpolation='bilinear')
plt.axis('off')
plt.show()